home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1997 #1 / Amiga Plus CD - 1997 - No. 01.iso / pd / programmierung / proasm / routines / tooltypes.r < prev    next >
Encoding:
Text File  |  1993-05-25  |  4.0 KB  |  223 lines

  1.  
  2. ;---;  tooltypes.r  ;----------------------------------------------------------
  3. *
  4. *    ****    GET TOOLTYPES FROM A WWORKBENCH PROGRAM    ****
  5. *
  6. *    Author        Stefan Walter
  7. *    Version        1.08
  8. *    Last Revision    25.05.93
  9. *    Identifier    gtt_defined
  10. *    Prefix        gtt_    (Get tooltypes)
  11. *                 ¯   ¯   ¯
  12. *    Functions    OpenIcon, CloseIcon, GetToolType
  13. *
  14. *    Note:    Dos.library should already be opened with OpenDosLib or
  15. *        by EasyLibraryHandler.
  16. *
  17. ;------------------------------------------------------------------------------
  18.  
  19. ;------------------
  20.     ifnd    gtt_defined
  21. gtt_defined    =1
  22.  
  23. ;------------------
  24. gtt_oldbase    equ __base
  25.     base    gtt_base
  26. gtt_base:
  27.  
  28. ;------------------
  29.  
  30. ;------------------------------------------------------------------------------
  31. *
  32. * OpenIcon    Prepare everything to read tooltypes from a WB program.
  33. *
  34. * INPUT:    a0    WB message
  35. *
  36. * RESULT:    d0    0: Error, -1: OK   (CCR set)
  37. *
  38. ;------------------------------------------------------------------------------
  39.  
  40. ;------------------
  41. OpenIcon:
  42.  
  43. ;------------------
  44. ; Do everything.
  45. ;
  46. \start:
  47.     movem.l    d1-a6,-(sp)
  48.     lea    gtt_base(pc),a4
  49.     move.l    a0,d7
  50.  
  51.     lea    gtt_iconname(pc),a1
  52.     move.l    4.w,a6
  53.     jsr    -408(a6)        ;OldOpenLibrary()
  54.     move.l    d0,gtt_iconbase(a4)
  55.     beq.s    \error
  56.  
  57. \changedir:
  58.     moveq    #0,d4
  59.     move.l    d7,a2
  60.     move.l    36(a2),a3        ;ArgList
  61.     move.l    (a3),d1
  62.     beq.s    \error2            ;no lock=>can't be
  63.     IFD     ely_defined
  64.     move.l    DosBase(pc),a6
  65.     ELSE
  66.     bsr    GetDosBase
  67.     ENDIF
  68.     jsr    -126(a6)        ;CurrentDir()
  69.     move.l    d0,gtt_oldlock(a4)    ;remember old lock
  70.  
  71. \getdiskobject:
  72.     move.l    4(a3),a0        ;name
  73.     move.l    gtt_iconbase(pc),a6
  74.     jsr    -78(a6)            ;GetDiskObject()
  75.     move.l    d0,gtt_object(a4)
  76.     beq.s    \error3
  77.     move.l    d0,a0
  78.     lea    54(a0),a0        ;ToolTypeArray
  79.     move.l    a0,gtt_array(a4)
  80.  
  81. \okay:
  82.     st.b    gtt_open(a4)
  83.     moveq    #-1,d0
  84. \exit:    movem.l    (sp)+,d1-a6
  85.     rts
  86.  
  87. ;------------------
  88. ; Errors => Clean up
  89. ;
  90. \error3:
  91.     move.l    gtt_oldlock(pc),d1
  92.     IFD     ely_defined
  93.     move.l    DosBase(pc),a6
  94.     ELSE
  95.     bsr    GetDosBase
  96.     ENDIF
  97.     jsr    -126(a6)        ;CurrentDir()
  98.  
  99. \error2:
  100.     move.l    gtt_iconbase(pc),a1
  101.     move.l    4.w,a6
  102.     jsr    -414(a6)        ;CloseLibrary()
  103.  
  104. \error:
  105.     clr.b    gtt_open(a4)
  106.     moveq    #0,d0
  107.     bra.s    \exit
  108.     
  109. ;------------------
  110.  
  111. ;------------------------------------------------------------------------------
  112. *
  113. * CloseIcon    Free all resources used for icon handling.
  114. *
  115. ;------------------------------------------------------------------------------
  116.  
  117. ;------------------
  118. CloseIcon:
  119.  
  120. ;------------------
  121. ; Do everything.
  122. ;
  123. \start:    movem.l    d0-a6,-(sp)
  124.     lea    gtt_base(pc),a4
  125.     tst.b    gtt_open(a6)
  126.     beq.s    \done
  127.     clr.b    gtt_open(a6)
  128.  
  129.     move.l    gtt_object(pc),a0
  130.     move.l    gtt_iconbase(pc),a6
  131.     jsr    -90(a6)            ;FreeDiskObj()
  132.  
  133.     move.l    gtt_oldlock(pc),d1
  134.     IFD     ely_defined
  135.     move.l    DosBase(pc),a6
  136.     ELSE
  137.     bsr    GetDosBase
  138.     ENDIF
  139.     jsr    -126(a6)        ;CurrentDir()
  140.  
  141.     move.l    gtt_iconbase(pc),a1
  142.     move.l    4.w,a6
  143.     jsr    -414(a6)        ;CloseLibrary()
  144.  
  145. \done:
  146.     movem.l    (sp)+,d0-a6
  147.     rts
  148.     
  149. ;------------------
  150.  
  151. ;------------------------------------------------------------------------------
  152. *
  153. * GetToolType    Get the argument after a tool type
  154. *
  155. * INPUT        a0    Buffer
  156. *        a1    ToolType to search for
  157. *        d0    Maximum length (zero excluded)
  158. *
  159. * RESULT    d0    Length of copied text or -1 if no such ToolType (CCR)
  160. *
  161. ;------------------------------------------------------------------------------
  162.  
  163. ;------------------
  164. GetToolType:
  165.  
  166. ;------------------
  167. ; Do everything.
  168. ;
  169. \start:
  170.     movem.l    d1-a6,-(sp)
  171.     lea    gtt_base(pc),a4
  172.     move.l    a0,d7
  173.     move.l    d0,d6
  174.  
  175.     move.l    gtt_array(pc),a0
  176.     move.l    gtt_iconbase(pc),a6
  177.     jsr    -96(a6)            ;FindToolType()
  178.     tst.l    d0
  179.     beq.s    \error
  180.  
  181.     move.l    d0,a1
  182.     move.l    d7,a0
  183.     moveq    #-1,d0
  184. \copy:    addq.l    #1,d0
  185.     move.b    (a1)+,(a0)+
  186.     beq.s    \done
  187.     subq.l    #1,d6
  188.     bne.s    \copy
  189.  
  190. \done:    tst.l    d0
  191.     bra.s    \exit
  192.  
  193. \error:    moveq    #-1,d0
  194. \exit:    movem.l    (sp)+,d1-a6
  195.     rts
  196.  
  197. ;------------------
  198.  
  199. ;--------------------------------------------------------------------
  200.  
  201. ;------------------
  202. gtt_iconname:    dc.b    "icon.library",0,0
  203. gtt_iconbase:    dc.l    0
  204. gtt_oldlock:    dc.l    0
  205. gtt_array:    dc.l    0
  206. gtt_object:    dc.l    0
  207.  
  208. gtt_open:    dc.b    0    ;set if all open
  209.         dc.b    0
  210.  
  211. ;------------------
  212.  
  213. ;--------------------------------------------------------------------
  214.  
  215. ;------------------
  216.     base    gtt_oldbase
  217.  
  218. ;------------------
  219.     endif
  220.  
  221.     end
  222.  
  223.